const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
const toFixed = function (value) {
  return value.toFixed(0);
}
const scene_decode=function(e) {
  if (e === undefined)
    return {};
  let scene = decodeURIComponent(e),
    params = scene.split(','),
    data = {};
  for (let i in params) {
    var val = params[i].split(':');
    val.length > 0 && val[0] && (data[val[0]] = val[1] || null)
  }
  console.log('data', data)
  return data;
}
module.exports = {
  formatTime: formatTime,
  toFixed: toFixed,
  scene_decode:scene_decode
}